import 'package:flutter/material.dart';
import 'widgets/sleep_tracking_card.dart';
import 'config/sleep_theme.dart';
import 'models/sleep_data_model.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '睡眠追踪演示',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const SleepTrackerScreen(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class SleepTrackerScreen extends StatelessWidget {
  const SleepTrackerScreen({super.key});

  // 示例睡眠数据
  static const List<List<int>> sampleData = [
    [2, 2], [4, 40], [2, 45], [3, 31], [1, 20], [2, 30], [1, 10], 
    [2, 9], [3, 30], [1, 20], [2, 140], [1, 20], [2, 24], [3, 11], [2, 49]
  ];

  // 示例饼图数据（分钟为单位）
  static const Map<SleepStage, int> samplePieChartData = {
    SleepStage.light: 299, // 4小时59分钟
    SleepStage.deep: 70,   // 1小时10分钟
    SleepStage.awake: 40,  // 40分钟
    SleepStage.rem: 72,    // 1小时12分钟
  };

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFF1a1a1a),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(20.0),
                    child: SleepTrackingCard.fromRawData(
            sampleData,
            theme: const SleepTrackingTheme(), // 使用默认主题
            pieChartData: samplePieChartData, // 传入饼图数据
            enableDebug: true, // 启用调试模式
            onBarTap: (dataPoint, index) {
              debugPrint('柱状图点击: $dataPoint at index $index');
            },
          ),
        ),
      ),
    );
  }
}
